/**
 * 前台分类关联修改详情页名称
 * @author linfeng
 * @since 2020/04/17
 */
layui.define(['form', 'layedit', 'laydate'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;

    form.render(null, "zmn-form");

    // 提交
    form.on('submit(zmn-form-submit)', function(obj){
        var openId = layer.open({type: 3});
        let data ={id: obj.field.groupId, desc: obj.field.desc};
        var url = "/serv/showCateg/ass/updateDesc.action";
        $.ajax({
            async: false,
            type: "POST", url: url,
            dataType: "json", data: data,
            success:function(result) {
                layer.close(openId);
                if(result.status == 200) {
                    layer.msg(result.message,{time: 1000},()=>{
                        zmnLayUtil.closeThisIframeMsg(parent, result.message, "zmn-table");
                        parent.location.reload();
                    });
                } else {
                    layer.msg(result.message, {"icon": 2});
                }
            },
            error:function(XMLHttpRequest, textStatus, errorThrown){
                layer.close(openId);
            }
        })

        return false;
    });

    //点击取消
    $(document).on('click', '#cancel', function () {
        let index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index);
    });


    //对外暴露的接口
    exports('art_serv_ass_category_show_detail', {});
});